package com.gitee.wsl.platform.network.command

typealias Consumer<T> = (T)->Unit

interface ICommandServer<ServerConfig> {
    val serverConfig: ServerConfig?

    fun setCommandHandler(handler: ICommandHandler?)

    fun start()

    fun stop()

    val isActive: Boolean

    fun setOnChannelOpen(onChannelOpen: Consumer<String>)

    fun setOnChannelClose(onChannelClose: Consumer<String>)

    fun newCommand(cmd: Short, flags: Short, data: String): BinaryCommand /*{
        return BinaryCommand.newCommand(this.serverConfig, cmd, flags, data)
    }*/

    fun broadcast(command: BinaryCommand)

    fun sendTo(addr: String, command: BinaryCommand)

    fun waitConnected(timeout: Long): Boolean
}


